<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
//
//Route::middleware('auth:api')->get('/user', function (Request $request) {
//    return $request->user();
//});
//Route::group(["namespace"=>'Api'],function (){
//    Route::get('getInfo','TestController@index');
//    Route::post('logout','TestController@index');
//    Route::post('login','TestController@login');
//});
//没有登录
Route::group(["namespace" => 'Api'], function () {
    //用户相关
    Route::group(["prefix" => 'user'], function ($router) {

        $router->post('register', 'UserController@registerUser');//账号密码注册
        $router->post('login_pass', 'UserController@loginPass');//密码登录
        $router->post('mini_login', 'UserController@miniLogin');//小程序登录
    });
    Route::group(["prefix" => 'platform'], function ($router) {
        $router->post('captcha', 'PlatformController@captchaCreate');//验证码
        $router->post('validate', 'PlatformController@validateCaptcha');//验证验证码
        $router->get('pay_method', 'PlatformController@payMethodList');//支付方式
    });
});

//不要求强制登录
Route::group(["namespace" => 'Api', 'middleware' => ['user']], function () {
    Route::group(["prefix" => 'user'], function ($router) {
    });
    Route::group(["prefix" => 'goods'], function ($router) {
        $router->get('lists', 'GoodsController@lists');//商品列表
        $router->get('detail', 'GoodsController@detail');//商品详情
        $router->get('cycle', 'GoodsController@cycle');//商品付款周期
    });
    Route::get('category/lists', 'CourseController@categoryLists');//课程分类
    Route::group(["prefix" => 'platform'], function ($router) {

    });

});

//要求登录
Route::group(["namespace" => 'Api', 'middleware' => ['user.auth']], function () {
    Route::group(["prefix" => 'user'], function ($router) {
        $router->get('main', 'UserCenterController@userInfo');
        $router->post('save', 'UserCenterController@updateUserInfo');
    });

    Route::group(["prefix" => 'order'], function ($router) {
        $router->get('lists', 'OrderController@lists');
        $router->post('create', 'OrderController@createOrder');
        $router->get('detail', 'OrderController@orderDetail');
        $router->post('cancel', 'OrderController@orderCancel');
        $router->get('check', 'OrderController@orderCheck');
    });
    Route::group(["prefix" => 'trade'], function ($router) {
        $router->post('to_pay', 'TradeController@toPay');//去支付
    });

    Route::group(["prefix" => 'upload'], function ($router) {
        $router->post('images', 'uploadController@upload');
    });

});

